function a=subsasgn(a,s,x)

  sd = s;
  I = reshape(1:numel(a.v),size(a.v));
  I = subsref(I,s);

  
  switch s.type
   case '()'
    if ~isa(x,'deriv1s')
      a.v = subsasgn(a.v,s,x);
      a.d(I,:) = 0;
    else
      a.v = subsasgn(a.v,s,x.v);
      a.d(I,:) = x.d;
    end
   otherwise
    error('wrong index type for_ deriv1s');
  end
